feat: add local file-based eligibility cache with --refresh flag - #20
Merged
Conversation
Cache eligibility API responses in ~/.grant/cache/ to skip the API roundtrip on subsequent runs. Default TTL is 4 hours, configurable via cache_ttl in ~/.grant/config.yaml. - internal/cache: generic Store with Get/Set/Invalidate and TTL expiry - internal/cache: CachedEligibilityLister decorator for both cloud and groups eligibility interfaces with verbose logging on hit/miss/refresh - --refresh flag on grant and grant env to bypass cache - cache_ttl config option with ParseCacheTTL helper - groups model types added as prerequisite for cache interface
aaearon
force-pushed
the
feat/eligibility-cache
branch
from
February 19, 2026 14:57
88754a2 to
01f233e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
~/.grant/cache/) that stores API responses as JSON files with a 4-hour default TTL, avoiding redundant API roundtrips on subsequent runs--refreshflag ongrantandgrant envto bypass the cache and fetch fresh eligibility datacache_ttlconfig option in~/.grant/config.yamlfor customizing the TTL (Go duration syntax, e.g.2h,30m)Details
cache.StorewithGet[T]/Set[T]functions and injectable clock for testingCachedEligibilityListerdecorator wraps both cloud and groups eligibility listers, implementing the existing interfaces transparentlybuildCachedLister()factory incmd/root.goshared by root and env commandseligibility_azure.json,eligibility_aws.json)Test plan
cache.Store(hit, miss, expiry, invalidation, corrupt data)CachedEligibilityLister(cache hit skips API, cache miss calls API and writes, refresh bypasses read, groups eligibility caching)config.ParseCacheTTL(default, custom, invalid)--refreshon root and env commandsmake testpasses